// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import Vuex from 'vuex' //引入状态管理
import store from './store'
import echarts from 'echarts'//表格可视化
import moment from 'moment'//时间格式处理
import utils from './utils/utils'

Vue.prototype.$moment = moment
Vue.prototype.$echarts = echarts
Vue.prototype.$utils = utils
Vue.use(Vuex) ;
Vue.prototype.axios = axios;
Vue.use(ElementUI)
Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
    if (to.meta.requireAuth) {
      if (store.state.result.status==200) {
        next()
      } else {
        next({
          path: 'login',
          query: {redirect: to.fullPath}
        })
      }
    } else {
      next()
    }
  }
)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
